<Query Kind="Statements" />

MyClass _object = new();
_object.SetState(new CircleManualState(_object));

public interface IControlState
{
    public void EntryState();
    public void ExitState();
}

public class DefaultState : IControlState
{
    public MyClass _object;

    public DefaultState(MyClass _class)
    {
        _object = _class;
    }

    public void EntryState() => Console.WriteLine($"Entry Default State");
    public void ExitState() => Console.WriteLine($"Exit Default State");
}

public class CircleManualState : IControlState
{
    public MyClass _object;

    public CircleManualState(MyClass _class)
    {
        _object = _class;
    }

    public void EntryState() => Console.WriteLine($"{_object.Name} 进入 Circle Manual");
    public void ExitState() => Console.WriteLine($"{_object.Name} 退出 Circle Manual");
}

public class MyClass
{
    public string Name { get; set; } = "Instance";
    IControlState? CurrentState { get; set; }

    public MyClass()
    {
        SetState(new DefaultState(this));
    }

    public void SetState(IControlState _state)
    {
        CurrentState?.ExitState();

        CurrentState = _state;
        _state.EntryState();
    }
}
